using System.Collections.Generic;
using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	internal class OracleLpTimeZoneExpression : OracleLpExpression
	{
		protected OracleLpTimeZoneExpressionType m_vTZExpressionType;

		protected OracleLpExpression m_vTZExpression;

		protected string m_vTZLiteral;

		public OracleLpTimeZoneExpressionType TZExpressionType
		{
			get
			{
				return m_vTZExpressionType;
			}
			set
			{
				m_vTZExpressionType = value;
			}
		}

		public OracleLpExpression TZExpression
		{
			get
			{
				return m_vTZExpression;
			}
			set
			{
				m_vTZExpression = value;
			}
		}

		public string TZLiteral
		{
			get
			{
				return m_vTZLiteral;
			}
			set
			{
				m_vTZLiteral = value;
			}
		}

		public OracleLpTimeZoneExpression(OracleLpStatementElement parent)
			: base(parent)
		{
			m_vExpressionType = OracleLpExpressionType.UNDEFINED;
		}

		public override void EvaluateDatatype()
		{
		}

		public override IList<OracleLpExpression> GetAllTerminalExpressions()
		{
			if (m_vAllTerminalExpressions == null)
			{
				m_vAllTerminalExpressions = new List<OracleLpExpression>();
				if (m_vTZExpressionType == OracleLpTimeZoneExpressionType.EXPRESSION)
				{
					m_vAllTerminalExpressions.Add(m_vTZExpression);
				}
				else
				{
					m_vAllTerminalExpressions.Add(this);
				}
			}
			return m_vAllTerminalExpressions;
		}

		internal override void ToString(StringBuilder sb)
		{
			base.ToString(sb);
			sb.Append("  TIME ZONE: ");
			switch (m_vTZExpressionType)
			{
			case OracleLpTimeZoneExpressionType.EXPRESSION:
				m_vTZExpression.ToString(sb);
				break;
			case OracleLpTimeZoneExpressionType.DBTIMEZONE:
				sb.Append("DBTIMEZONE");
				break;
			case OracleLpTimeZoneExpressionType.STRING_LITERAL:
				sb.Append(m_vTZLiteral);
				break;
			}
		}
	}
}
